package com.wx.generic.clazz;


import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

/**
 * 泛型类
 *
 * @author wang.xun
 * @date 2022/12/23
 */
@Slf4j
public class GenericClazz {




    @Test
    public void testBasket(){
        Basket<String> stringBasket = new Basket<>();
        stringBasket.setFood("大米");


        Assert.assertTrue("String类型不匹配", String.class.isInstance(stringBasket.getFood()));


        Basket<Apple> appleBasket = new Basket<>();
        appleBasket.setFood(new Apple());

        Assert.assertTrue("Apple类型不匹配", Apple.class.isInstance(appleBasket.getFood()));
    }




}
